<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">
<head>
	<title></title>
</head>     
 
<body>
	<h:form>
		<s:validateAll>
			<s:message></s:message>
			
			<f:facet name="aroundInvalidField">
				<s:span styleClass="errors"></s:span>
			</f:facet>
			
			<f:facet name="afterInvalidField">
				<s:message showSummary="true" showDetail="false"></s:message>
			</f:facet>
			
			<h:panelGroup id="UserForm">
				<fieldSet>
					<h:messages id="messages" globalOnly="true" style="color: red" layout="table"/>
					<h:inputHidden value="#{userBean.user.id}" />
					<table>
					
					<tr>
						<td>Name:</td>
						<td><s:decorate><input type="text" name="name" jsfc="h:inputText" label="Name" value="#{userBean.user.name}" required="true"/></s:decorate></td>
					</tr>
					
					<tr>
						<td>Username:</td>
						<td><s:decorate><input type="text" name="username" jsfc="h:inputText" label="Username" value="#{userBean.user.username}" required="true"/></s:decorate></td>
					</tr>
					
					<tr>
						<td>Password:</td>
						<td><s:decorate><input type="text" name="password" jsfc="h:inputSecret" label="Password" value="#{userBean.user.password}" required="true"/></s:decorate></td>
					</tr>
					
					<tr>
						<td>Verify Password:</td>
						<td><s:decorate><input type="text" name="verify" jsfc="h:inputSecret" label="Verify Password" value="#{userBean.verifyPassword}" required="true"/></s:decorate></td>
					</tr>
					
					</table>
					
				</fieldSet>
				
			</h:panelGroup>
		</s:validateAll>
		
		<input type="button" name="saveButton" jsfc="a4j:commandButton" value="Save" action="#{userBean.save}" reRender="UserForm, UserList" limitToList="false"/>
		<a4j:region>
			<input type="button" name="newButton" jsfc="a4j:commandButton" value="New" action="#{userBean.newUser}" reRender="UserForm" limitToList="false"/>
		</a4j:region>
	</h:form>
	
	<h:form prependId="false" id="ListForm">
		<h:dataTable value="#{users}" var="usr" id="UserList">
			<h:column>
				<f:facet name="header">
					Name
				</f:facet>
				#{usr.name}
			</h:column>
			
			<h:column>
				<f:facet name="header">
					Username
				</f:facet>
				#{usr.username}
			</h:column>
			
			<h:column>
				<f:facet name="header">
					Password
				</f:facet>
				#{usr.password}
			</h:column>
			
			<h:column>
				<f:facet name="header">
					Actions
				</f:facet>
				<s:button id="EditButton" action="#{userBean.edit}" value="Edit"></s:button>
				<s:button id="DeletarButton" action="#{userBean.delete}" value="Delete"></s:button>
			</h:column>
		</h:dataTable>
	</h:form>
</body>

</html>